package com.guqj.pattern.observer;

public class StatisticsDisplay implements Observer, DisplayElement {

	private float temperature; // 温度  
    private float humidity; // 湿度
	@SuppressWarnings("unused")
	private Subject weatherData = null;

	public StatisticsDisplay(WeatherData weatherData) {
		this.weatherData = weatherData;
		weatherData.registerObserver(this);
	}

	@Override
	public void display() {
		System.out.println("Statistics: " + temperature + "F degrees and " + humidity + "% humidity");

	}

	@Override
	public void update(float temperature, float humidity, float pressure) {
		this.temperature = temperature;
		this.humidity = humidity;
		display();
	}

}
